<?php

namespace farm;

use farm\dao\Machine;
use farm\dao\Users;
use farm\utils\ApiUtils;
use farm\utils\Db;

class FarmRegister
{
    public static function test(): string
    {
        return date('Y-m-d H:i:s');
    }

    public static function register()
    {

        extract(ApiUtils::getParams());
//        $id = Users::insert([
//            'account' => $account + rand(1, 6),
//            'passwd' => ApiUtils::password($passwd),
//            'state' => Users::getNormalState(),
//            'created_at' => ApiUtils::now(),
//        ]);

        $id = Machine::insert([
            [
                'name' => "收割机",
                'type' => 20,
                'brand' => '未知品牌',
                'no' => '188178387173',
                'state' => Machine::getNormalState(),
                'uid' => 24,
                'working_oil_wear' => 24.20,
                'working_performance' => 0.75,
            ],
            [
                'name' => "收割机2号",
                'type' => 20,
                'brand' => '未知品牌',
                'no' => '188178387173',
                'state' => Machine::getNormalState(),
                'uid' => 24,
                'working_oil_wear' => 24.20,
                'working_performance' => 0.75,
            ],
        ]);

        return [
            'insert_id' => $id,
            'list' => Machine::select([],['id','name']),
        ];
    }
}
